package com.imooc.sell.dataobject;

import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 统计抽象类
 */
@Data
public abstract class AbstractStat {

    private Integer sellSuccess;
    private BigDecimal successSale;
    private Integer sellCancel;
    private Integer sellPayback;
    private Date date;

    /**
     * 将空对象转换为非空对象
     *
     * @param o     要检查的对象
     * @param clazz 对象的类型
     * @return 处理后的非空对象
     */
    protected Object check(Object o, Class<?> clazz) {
        Object oo;
        Object default_value1 = 0;
        Object default_value2 = new BigDecimal(0);
        if (clazz == BigDecimal.class) {
            oo = default_value2;
        } else {
            oo = default_value1;
        }
        return (null == o ? oo : o);
    }

    public abstract void upToDad();
}
